package com.iyeed.jbpm04.demo05.tasknotify;

import java.util.concurrent.TimeUnit;

import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.taskmgmt.exe.TaskInstance;
import org.junit.Test;

public class TaskNotifyTest {

	@Test
	public void testTaskNotify() {
		JbpmContext jcontext = JbpmConfiguration.getInstance().createJbpmContext();
		try {
			ProcessInstance pi = jcontext.newProcessInstance("tasknotifyprocess");
			pi.signal();
		} finally {
			jcontext.close();
		}
	}
	
	
	@Test
	public void testJob() throws InterruptedException {
		JbpmConfiguration.getInstance().getJobExecutor().start();
		TimeUnit.HOURS.sleep(10);
	}
	
	
	@Test
	public void testCloseTaskNotify() {
		JbpmContext jcontext = JbpmConfiguration.getInstance().createJbpmContext();
		try {
			TaskInstance ti = (TaskInstance) jcontext.getTaskList("iyeed").iterator().next();
			System.out.println(ti.getToken().getNode().getName());
			ti.end();
		} finally {
			jcontext.close();
		}
	}
	
}
